package com.mopa.utils;

import android.media.ExifInterface;

public class ImageUtils {
	public static int getJpgRotation(String img)
	{
		if(img == null)
			return 0;
		if(img.endsWith(".jpg") == false && img.endsWith(".JPG") ==  false && img.endsWith(".dat") == false)
			return 0;
		ExifInterface exif;
		try {
			exif = new ExifInterface(img);
			String r = exif.getAttribute(ExifInterface.TAG_ORIENTATION);
			if(r != null && r.length() > 0)
			{
				int ori =  Integer.parseInt(r);
				switch(ori)
				{
				case ExifInterface.ORIENTATION_ROTATE_90:
					return 90;
				case ExifInterface.ORIENTATION_ROTATE_180:
					return 180;
				case ExifInterface.ORIENTATION_ROTATE_270:
					return 270;
				}
			}
		} catch (Exception e) {
		}
		return 0;
	}
 
}
